-
-
Notifications
You must be signed in to change notification settings - Fork 325
feat: Exploration of ppr, dynamicIO and next/root-params
#1531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
amannn
wants to merge
43
commits into
v4
Choose a base branch
from
feat/next-future
base: v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…ply, static messages import
ppr, dynamicIO & friendsppr, dynamicIO & friends
amannn
commented
Nov 19, 2024
|
|
||
| return { | ||
| locale, | ||
| messages: (await import(`../../messages/${locale}.json`)).default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Revert
# Conflicts: # examples/example-app-router/package.json # examples/example-app-router/src/app/[locale]/layout.tsx # examples/example-app-router/src/app/[locale]/page.tsx # examples/example-app-router/src/app/[locale]/pathnames/page.tsx # examples/example-app-router/src/app/manifest.ts # examples/example-app-router/src/components/BaseLayout.tsx # pnpm-lock.yaml
# Conflicts: # examples/example-app-router/src/app/[locale]/layout.tsx
# Conflicts: # examples/example-app-router/next.config.mjs
ppr, dynamicIO and rootParamsppr, dynamicIO and next/root-params
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An exploration of how
next-intlcan adapt better forppr,dynamicIOandrootParams(see #1493).Centralized validation of
[locale]segment withdynamicParams = falseIf params can be read statically, we could use
dynamicParams = falseto return a 404 for unknown locales (see d1a0308).However, it seems like this isn't a good idea to introduce yet:
rootParams. If that's the case, this could simplify the usage for the common case, but maybe we need to cover the case for unknown locales earlier in the docs.dynamicParamsis not compatible withdynamicIO—and maybe never will:However, it seems like Next.js is working on an alternative to
dynamicParams = false. With this, maybe we'll have a reasonable solution for centralized validation of the[locale]segment.EDIT: I've opened vercel/next.js#84991 for further discussion.
Usage of
setRequestLocaleCalling
setRequestLocalewithin a'use cache'boundary doesn't seem to work. We need to wait forrootParamsto get rid of this API.Reading the
localeparam without suspendingCurrently not easily possible, waiting for an alternative to
dynamicParams = false: vercel/next.js#71927.What did work in my test though is to use
'use cache'on both the layout and page entry point. This might not fit your application though and furthermore makes it impossible to read request-specific params in components. EDIT: It only works in dev, not when building the app.Another use case to be tested would be mixing a statically known
[locale]param with a dynamic child page (see https://nextjs.org/blog/our-journey-with-caching#partial).Importing of JSON messages
Dynamic imports currently cause an error: vercel/next.js#72589.
Effect of
use(…)andawaitFor the APIs that
next-intloffers, these seem to not require a suspense boundary for async data—that's helpful.Effect of client-side hooks on caching
Hooks like
useParams,useSelectedLayoutSegmentandusePathnamework fine in development but error out during the build when used in a dynamic segment like[locale], asking for a suspense boundary or'use cache'. Not sure what the expected behavior is, but there's definitely an inconsistency here. See vercel/next.js#72756.EDIT: This would probably also require a replacement for
dynamicParams = false.Conclusion
ppranddynamicIOmight work (but requires feat!: Remove default ofnow={new Date()}fromNextIntlClientProviderfor usage withformat.relativeTime(preparation fordynamicIO) #1536)However, it seems like with #1412 users can adopt these modes without any changes necessary in
next-intl.Once
rootParamsis a thing, we can:rootParamsini18n/request.ts.getLocale()instead of reading from params in components. This can be strongly-typed and potentially overridden.getTranslations({locale: …})should only be relevant for overriding locales, not for enabling static rendering. We might want to re-introduce a sync({locale})arg for this use case though.({locale})for overriding a locale (this is now only an edge case for apps that render with multiple locales simultaneously on the server). Also: Warn if({locale})is passed togetRequestConfigbut not read.[locale]segment and also don't need to bump the peer dependency aggressively once this API is introduced sincenext-intldoesn't read from it.await requestLocaleoncerootParamsis stable and supported for some time. Consider that users on older Next.js versions will still rely on this until they've upgraded to a Next.js version that supportsrootParams—therefore don't deprecate too aggressively.setRequestLocale